package kz.kstu.shop.app.util.sync;

import kz.kstu.shop.app.delegate.api.SyncDelegate;
import kz.kstu.shop.app.delegate.impl.SyncDelegateImpl;
import kz.kstu.shop.business.entity.Synchronizable;
import kz.kstu.shop.business.entity.guide.Product;
import org.apache.log4j.Logger;

import java.util.List;

/**
 * @author Filipp_Stankevich
 *         created: 08.08.11 20:28
 */
public class GuideSyncLocalServiceImpl implements SyncLocalService {

    private final static Logger LOGGER = Logger.getLogger(GuideSyncLocalServiceImpl.class);

    @Override
    public void sync() {
        LOGGER.debug("Guide synchronization... started");
        SyncDelegate syncDelegate = new SyncDelegateImpl();
        List<Synchronizable> products = syncDelegate.findForSyncOnServer(Product.class, 0L);
        syncDelegate.saveSycnhronazableOffline(products);
        LOGGER.debug("Guide synchronization... ok");
    }
}
